www.gusucode.com > 超声波测量以及形成图像 对相关信号进行模拟仿真 > 超声波测量以及形成图像 对相关信号进行模拟仿真/digital holograpy/dh/rgunwrap_window.m

    function varargout = rgunwrap_window(varargin)
% RGUNWRAP_WINDOW M-file for rgunwrap_window.fig
%      RGUNWRAP_WINDOW, by itself, creates a new RGUNWRAP_WINDOW or raises the existing
%      singleton*.
%
%      H = RGUNWRAP_WINDOW returns the handle to a new RGUNWRAP_WINDOW or the handle to
%      the existing singleton*.
%
%      RGUNWRAP_WINDOW('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in RGUNWRAP_WINDOW.M with the given input arguments.
%
%      RGUNWRAP_WINDOW('Property','Value',...) creates a new RGUNWRAP_WINDOW or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before rgunwrap_window_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to rgunwrap_window_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help rgunwrap_window

% Last Modified by GUIDE v2.5 04-Sep-2007 21:27:43

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @rgunwrap_window_OpeningFcn, ...
                   'gui_OutputFcn',  @rgunwrap_window_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before rgunwrap_window is made visible.
function rgunwrap_window_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to rgunwrap_window (see VARARGIN)
handles.ssz=[10,10];
handles.phase=[];
handles.upm=[];

if nargin > 4
    for n=1:2:length(varargin)
        if strcmpi(varargin{n},'phasemaps')
            handles.phase=varargin{n+1};
        end
    end
end

% Choose default command line output for rgunwrap_window
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes rgunwrap_window wait for user response (see UIRESUME)
uiwait(handles.rgunwrap_window);


% --- Outputs from this function are returned to the command line.
function varargout = rgunwrap_window_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
if isempty(findobj('type','figure','tag','rgunwrap_window'))
    varargout{1}=[];
    return
end

varargout{1}=handles.upm;

delete(handles.rgunwrap_window)


% --- Executes during object creation, after setting all properties.
function ssz_edit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ssz_edit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function ssz_edit_Callback(hObject, eventdata, handles)
% hObject    handle to ssz_edit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of ssz_edit as text
%        str2double(get(hObject,'String')) returns contents of ssz_edit as a double
handles.ssz=round(abs(str2num(get(hObject,'string'))));
if length(handles.ssz)==1
    handles.ssz=[handles.ssz,handles.ssz];
end
if isempty(handles.ssz) || ~isequal(size(handles.ssz),[1,2])
    handles.ssz=[10,10];
end
handles.ssz(handles.ssz==0)=1;
set(hObject,'string',['[',num2str(handles.ssz(1)),',',num2str(handles.ssz(2)),']']);
guidata(hObject,handles)


% --- Executes when user attempts to close rgunwrap_window.
function rgunwrap_window_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to rgunwrap_window (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure
if isequal(get(handles.rgunwrap_window, 'waitstatus'), 'waiting')
    % The GUI is still in UIWAIT, us UIRESUME
    uiresume(handles.rgunwrap_window);
else
    % The GUI is no longer waiting, just close it
    delete(handles.rgunwrap_window);
end


% --- Executes on button press in unwrap_button.
function unwrap_button_Callback(hObject, eventdata, handles)
% hObject    handle to unwrap_button (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if isempty(handles.phase)
    return
end

items=sort(fieldnames(handles.phase));

prefix=get(handles.prefix_edit,'string');

for n=1:length(items)
    handles.upm(1).([prefix,items{n}])=regiongrow(handles.phase(1).(items{n}),...
        handles.ssz,handles.phase(4).(items{n}));
    handles.upm(1).([prefix,items{n}])(~handles.phase(4).(items{n}))=NaN;
    handles.upm(2).([prefix,items{n}])=handles.phase(2).(items{n});
    handles.upm(3).([prefix,items{n}])=handles.phase(3).(items{n});
    handles.upm(4).([prefix,items{n}])=handles.phase(4).(items{n});
end

guidata(hObject,handles)

set(hObject,'enable','off')
uiresume(handles.rgunwrap_window);


% --- Executes during object creation, after setting all properties.
function prefix_edit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to prefix_edit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function prefix_edit_Callback(hObject, eventdata, handles)
% hObject    handle to prefix_edit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of prefix_edit as text
%        str2double(get(hObject,'String')) returns contents of prefix_edit as a double
prefix=get(hObject,'string');
if ~isvarname(prefix)
    set(hObject,'string','')
end